//
// PageFaultAction.h
// Usage: Page fault exception action
// CreateDate: 2009-05-03
// Author: MaJiuyue
//
#ifndef _PAGEFAULT_ACTION_H_
#define _PAGEFAULT_ACTION_H_

#include <NewLife.h>
#include "../intrman/ExceptionAction.h"
#include "../schedule/Context.h"

class PageFaultAction : public ExceptionAction
{
private:
	static PageFaultAction * instance;
	PageFaultAction() {}
public:
	static PageFaultAction * GetInstance()
	{
		if(!instance)
			instance = new PageFaultAction;
		return instance;
	}

public:
	virtual void operator() (u32 vec_no, u32 err_code, u32 eip, u32 cs, u32 eflags);

private:
	void HandleKernelSpace(Context *context, addr_t cr2, u32 cs, u32 eip);
	void HandleUserSpace(Context *context, addr_t cr2, u32 cs, u32 eip);
};

#endif

